package allTests;

import abbot.util.AWTFixtureHelper;
import com.supermap.desktop.core.Application;
import operation.DialogOperation;
import operation.Operation;
import operation.WorkspaceTreeOperation;
import org.junit.*;
import robotCross.TipMatcher;
import util.Info;
import util.ListenCounts;

import static operation.Operation.robot;
import static socketEnv.Client.message;

/**
 * Created by caolp on 2017-05-02.
 * 将进行稳定性测试的方法都放到该类中
 */
public class TestStable {
	public static ListenCounts listenCounts = new ListenCounts();
	@BeforeClass
	public static void tearUp() {
		Info.out("BeforeClass:");
		Operation.helper = new AWTFixtureHelper();
		robot = Operation.helper.getRobot();
		//关闭所有对话框
		new DialogOperation().closeAllDialog();
		robot.delay(3000);
		try {
			listenCounts.getPID();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void staticsCouts() {
		try {
			listenCounts.startRecords();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@After
	public void closeWorkspace() throws Exception {
		try {
			listenCounts.endRecords();
		} catch (Exception e) {
			e.printStackTrace();
		}
		new WorkspaceTreeOperation().selectWorkspaceNodeMenu("关闭工作空间");
		robot.delay(2000);
		new DialogOperation().clickComponent(new TipMatcher("确定"));
		new DialogOperation().clickComponent(new TipMatcher("否"));
	}

	@AfterClass
	public static void realseResource() {
		listenCounts.closeWorkSpace();
	}

	@Test
	public void testUniqueTheme() throws Exception {
		Application.getActiveApplication().getOutput().output("第1个测试用例" + message.getMethodName());


	}

	@Test
	public void testUniqueTheme2() throws Exception {
		Application.getActiveApplication().getOutput().output("第2个测试用例" + message.getMethodName());

	}

	@Test
	public void testUniqueTheme3() throws Exception {
		Application.getActiveApplication().getOutput().output("第3个测试用例" + message.getMethodName());

	}
}
